<?php
$username = $_POST['username'];
include_once 'conn.php';
$sql = "select * from userinfo where username = '$username'";
$result = mysqli_query($conn,$sql);
if(mysqli_num_rows($result)){
    //说明此用户名已经被占用，不可使用
    $msg['error'] = 1;
}
else{
    $msg['error'] = 0;
}
echo json_encode($msg);